home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-26 | 4.4 KB | 142 lines | [TEXT/R*ch] |
- /*
- File: CCommunicationPanel.cp
-
- Contains: Class stub to use as a template for creating your own multi-pane
- dialog panels.
-
- Written by: Mike Shields
-
- Copyright: Copyright © 1996 Mike Shields. All Rights Reserved.
-
- Change History (most recent first):
-
- 02/01/96 MSS New
- To Do:
- */
- #include "CCommunicationPanel.h"
-
- #include <LStream.h>
- #include <LControl.h>
- #include <LEditField.h>
-
- #ifndef __Dialogs__
- #include <Dialogs.h>
- #endif
-
- #pragma options align=mac68k
- struct SCommPanelRec
- {
- Int16 encrypt;
- Int16 universalTrans;
- Int16 commMode;
- Int32 commFreq;
- };
- #pragma options align=reset
-
- typedef struct SCommPanelRec CommPanelDataRec, *CommPanelDataPtr, **CommPanelDataHandle;
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::CreateFromStream
- //---------------------------------------------------------------------------
- CCommunicationPanel* CCommunicationPanel::CreateFromStream(LStream* inStream)
- {
- return (new CCommunicationPanel(inStream));
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::CCommunicationPanel
- //---------------------------------------------------------------------------
- CCommunicationPanel::CCommunicationPanel()
- {
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::CCommunicationPanel
- //---------------------------------------------------------------------------
- CCommunicationPanel::CCommunicationPanel(const CCommunicationPanel &inOriginal)
- : CMPDPanel(inOriginal)
- {
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::CCommunicationPanel
- //---------------------------------------------------------------------------
- CCommunicationPanel::CCommunicationPanel(const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo)
- : CMPDPanel(inPaneInfo, inViewInfo)
- {
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::CCommunicationPanel
- //---------------------------------------------------------------------------
- CCommunicationPanel::CCommunicationPanel(LStream *inStream)
- : CMPDPanel(inStream)
- {
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::CCommunicationPanel
- //---------------------------------------------------------------------------
- CCommunicationPanel::~CCommunicationPanel()
- {
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::GetData
- //---------------------------------------------------------------------------
- void CCommunicationPanel::GetData(Handle inDataToReplace)
- {
- LControl *aControl;
- LEditField *aField;
- CommPanelDataRec newPrefs;
-
- aControl = (LControl*)this->FindPaneByID('Encr');
- newPrefs.encrypt = aControl->GetValue();
- aControl = (LControl*)this->FindPaneByID('Univ');
- newPrefs.universalTrans = aControl->GetValue();
- aControl = (LControl*)this->FindPaneByID('Mode');
- newPrefs.commMode = aControl->GetValue();
- aField = (LEditField*)this->FindPaneByID('Freq');
- newPrefs.commFreq = aField->GetValue();
-
- OSErr anErr = ::PtrToXHand(&newPrefs, inDataToReplace, sizeof(newPrefs));
- ThrowIfOSErr_(anErr);
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::SetData
- //---------------------------------------------------------------------------
- void CCommunicationPanel::SetData(Handle inData)
- {
- LControl *aControl;
- LEditField *aField;
- CommPanelDataHandle newPrefs = (CommPanelDataHandle)inData;
-
- aControl = (LControl*)this->FindPaneByID('Encr');
- aControl->SetValue((**newPrefs).encrypt);
- aControl = (LControl*)this->FindPaneByID('Univ');
- aControl->SetValue((**newPrefs).universalTrans);
- aControl = (LControl*)this->FindPaneByID('Mode');
- aControl->SetValue((**newPrefs).commMode);
- aField = (LEditField*)this->FindPaneByID('Freq');
- aField->SetValue((**newPrefs).commFreq);
- }
-
- //---------------------------------------------------------------------------
- // CCommunicationPanel::ValidatePanel
- //---------------------------------------------------------------------------
- Boolean CCommunicationPanel::ValidatePanel()
- {
- LEditField *aField;
- aField = (LEditField*)this->FindPaneByID('Freq');
- if ( aField->GetValue() > 100 )
- {
- ::Alert(200, NULL);
- aField->SelectAll();
- LCommander::SwitchTarget(aField);
- return false;
- }
- return true;
- }
-
-